﻿Imports CommunityToolkit.Mvvm.ComponentModel
Imports CommunityToolkit.Mvvm.Input

Public Class MainLayoutViewModel
    Inherits ObservableObject

    ' 手动实现的属性（替代 [ObservableProperty]）
    Private _navigateTargetPageUri As Uri
    Public Property NavigateTargetPageUri As Uri
        Get
            Return _navigateTargetPageUri
        End Get
        Set(value As Uri)
            ' 使用基类的 SetProperty 方法触发通知
            SetProperty(_navigateTargetPageUri, value)
        End Set
    End Property

    ' 保留 MVVM Toolkit 的 RelayCommand 类型
    Public ReadOnly Property NavigateToHomePageCommand As RelayCommand
    Public ReadOnly Property NavigateToMyBlogPageCommand As RelayCommand
    Public ReadOnly Property NavigateToProfilePageCommand As RelayCommand
    Public ReadOnly Property NavigateToFollowingPageCommand As RelayCommand

    Public Sub New()
        ' 手动初始化命令
        NavigateToHomePageCommand = New RelayCommand(AddressOf NavigateToHomePage, AddressOf CanNavigateToHomePage)
        NavigateToMyBlogPageCommand = New RelayCommand(AddressOf NavigateToMyBlogPage, AddressOf CanNavigateToCommunityPage)
        NavigateToProfilePageCommand = New RelayCommand(AddressOf NavigateToProfilePage, AddressOf CanNavigateToProfilePage)
        NavigateToFollowingPageCommand = New RelayCommand(AddressOf NavigateToFollowingPage, AddressOf CanNavigateToFollowingPage)
        NavigateToHomePage()
    End Sub

    ' 导航方法（保持私有）
    Private Sub NavigateToHomePage()
        If NavigateTargetPageUri <> NavigationData.HOME_PAGE_URI Then
            NavigateTargetPageUri = NavigationData.HOME_PAGE_URI
        End If
    End Sub

    Private Sub NavigateToMyBlogPage()
        If NavigateTargetPageUri <> NavigationData.MY_BLOG_PAGE_URI Then
            NavigateTargetPageUri = NavigationData.MY_BLOG_PAGE_URI
        End If
    End Sub

    Private Sub NavigateToProfilePage()
        If NavigateTargetPageUri <> NavigationData.PROFILE_PAGE_URI Then
            NavigateTargetPageUri = NavigationData.PROFILE_PAGE_URI
        End If
    End Sub

    Private Sub NavigateToFollowingPage()
        If NavigateTargetPageUri <> NavigationData.FOLLOWING_PAGE_URI Then
            NavigateTargetPageUri = NavigationData.FOLLOWING_PAGE_URI
        End If
    End Sub

    ' 命令可用性检查（保持原有逻辑）
    Public Function CanNavigateToHomePage() As Boolean
        Return True
    End Function

    Public Function CanNavigateToCommunityPage() As Boolean
        Return True
    End Function

    Public Function CanNavigateToProfilePage() As Boolean
        Return True
    End Function

    Public Function CanNavigateToFollowingPage() As Boolean
        Return True
    End Function
End Class
